/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.assertj.ohos.api.ability;

import ohos.aafwk.ability.Form;

import org.assertj.core.api.AbstractAssert;

import static org.assertj.core.api.Assertions.assertThat;

/** 表单断言 */
public abstract class FormAssert<S extends FormAssert<S, A>, A extends Form>
        extends AbstractAssert<S, A> {
    public FormAssert(A actual, Class<S> selfType) {
        super(actual, selfType);
    }

    /**
     * bundle名称
     *
     * @param bundleName bundle名称
     * @return S
     */
    public S hasBundleName(String bundleName) {
    isNotNull();
    String actualBundleName = actual.getBundleName();
    assertThat(actualBundleName)
    .overridingErrorMessage("Expected deviceId <%s> but was <%s>.", bundleName, actualBundleName)
    .isEqualTo(bundleName);
        return myself;
    }

    /**
     * ability名称
     *
     * @param abilityName ability名称
     * @return S
     */
    public S hasAbilityName(String abilityName) {
    isNotNull();
    String actualAbilityName = actual.getAbilityName();
    assertThat(actualAbilityName) //
        .overridingErrorMessage("Expected title <%s> but was <%s>.", abilityName, actualAbilityName) //
        .isEqualTo(abilityName);
        return myself;
    }

    /**
     * 具有表单
     *
     * @param formName 表单名称
     * @return S
     */
    public S hasFormName(String formName) {
    isNotNull();
    String actualFormName = actual.getFormName();
    assertThat(actualFormName) //
            .overridingErrorMessage("Expected title <%s> but was <%s>.", formName, actualFormName) //
            .isEqualTo(formName);
        return myself;
    }

}
